package cn.backpackerxl.easyJDBC.util;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: backpackerxl
 * CreateTime: 2022/5/2
 * FileName: TableBean
 **/
public final class TableBean {
    private String tableName;
    private String key;
    private Object object;

    public TableBean() {
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public Object getObject() {
        return object;
    }

    public void setObject(Object object) {
        this.object = object;
    }

    public String getTableName(String suffix) {
        return tableName + " " + suffix.trim();
    }

    public BuildSQL getFNI(int idx) {
        return new BuildSQL(StringUtil.removeHump(this.object.getClass().getDeclaredFields()[idx].getName()));
    }

    public List<BuildSQL> getFNI(String prefix, String suffix, int... idx) {
        List<BuildSQL> buildSQL = new ArrayList<>();
        for (int i : idx) {
            buildSQL.add(new BuildSQL(StringUtil.removeHump(this.object.getClass().getDeclaredFields()[i].getName())).prefix(prefix.trim()).suffix(suffix.trim()));
        }
        return buildSQL;
    }

}
